package com.dayu.finecomm.protocol;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/***
 * ChannelInboundAdapter which just care about <b>T</b> , <br>
 * and will pass other messages to next Channel.
 * 
 */
public abstract class SpecialCareChannelInboundAdapter<T> extends SimpleChannelInboundHandler<T> {

	@SuppressWarnings("unchecked")
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		// 对解码的消息类型进行判断，通过类型参数校验器看是否是可接收的类型，如果是则校验通过
		if (acceptInboundMessage(msg)) {
			channelRead0(ctx, (T) msg);
		} else {
			// 继续往下传
			ctx.fireChannelRead(msg);
		}
	}

}
